package cn.xiongxf.feignclient;

import cn.xiongxf.domain.Movie;
import cn.xiongxf.domain.User;
import cn.xiongxf.domain.UserMovie;
import cn.xiongxf.util.AjaxResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.math.BigDecimal;
import java.util.List;

@FeignClient(value = "movie-server",fallbackFactory = MovieFeignClientFallbackFactory.class)
public interface MovieFeignClient {
    /**
     * OpenFeign调用Movie服务接口，默认底层会帮助我们创建动态代理实现类，会使用RestTemplate进行调用
     * Movie服务接口
     * @param
     * @return
     */
    @PostMapping("/add")
    AjaxResult add(@RequestBody User user);

    @GetMapping("/list")
    List<Movie> findAll();

    @PostMapping("/purchase")
    AjaxResult purchase(@RequestBody UserMovie userMovie);

    @GetMapping("/{id}")
    BigDecimal queryPrice(@PathVariable Long id);

    @GetMapping("/presented/{id}")
    void presented(@PathVariable Long id);

    @PostMapping("/watch")
    AjaxResult watch(@RequestBody UserMovie userMovie);
}
